package by.bsu.fpmi.bbtp.entities;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import javax.xml.bind.annotation.XmlType;

@XmlType(namespace = "entities.fpmi.bsu.by", name = "Good")
@Entity
@Table(name = "goods")
public class Good {
    
    private long id;
    private String name;
    private double price;

    @Transient
    public GoodHead getHead() {
        GoodHead head = new GoodHead();
        head.setId(id);
        head.setName(name);
        return head;
    }

    @Id
    @GeneratedValue(generator = "increment")
    @GenericGenerator(name = "increment", strategy = "increment")
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Column(name = "name", nullable = false, unique = true)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "price", nullable = false)
    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "{" +
                "name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}
